<template>
    <view>
        <view v-if="(data_base || null) != null" class="page_big">
			<!-- 通知 -->
			<view v-if="gonggao != ''" class="ggbox bg-white bg-white border-radius-main pr buyuanjiao">
				<uv-notice-bar :text="gonggao"></uv-notice-bar>
			</view>

            <!-- 积分卡片信息 -->
            <view class="padding-main zichan_top_box">
				<view class="zichan_top_title tc text-size">积分余额</view>
				<view class="zichan_top_num tc text-size-big">{{user_score.integral || '0.00'}}</view>
                <view class="padding-main bg-white pr" v-if="(data_base || null) != null && ((data_base.is_enable_recharge || 0) == 1 || (data_base.is_enable_cash || 0) == 1)">
                    <view class="zichan_btn_box oh">
                        <navigator v-if="(data_base || null) != null && (data_base.is_enable_recharge || 0) == 1" url="/pages/fcc/scorestore/recharge/recharge" hover-class="none">
                            <button class="bg-main br-main cr-white round text-size" type="default" hover-class="none">充值</button>
                        </navigator>
                        <navigator v-if="(data_base || null) != null && (data_base.is_enable_cash || 0) == 1" url="/pages/fcc/scorestore/cash-create/cash-create" hover-class="none">
                            <button class="cr-default-yxbtn br-main-default round text-size" type="default" hover-class="none">提现</button>
                        </navigator>
                    </view>
                </view>
            </view>

            <!-- 导航 -->
            <view v-if="nav_list.length > 0" class="nav oh">
                <block v-for="(item, index) in nav_list" :key="index">
                    <view class="item fl tc padding-main border-radius-main bg-white">
                        <navigator :url="item.url" hover-class="none">
                            <image :src="item.icon" mode="scaleToFill" class="dis-block"></image>
                            <view class="tc cr-base margin-top-lg">{{item.title}}</view>
                        </navigator>
                    </view>
                </block>
				<!-- 是否开了退出按钮 -->
				<view v-if="(data_base || null) != null && (data_base.is_show_out || 0) == 1" class="item fl tc padding-main border-radius-main bg-white" @tap="remove_user_cache_event">
					<image :src="scorestore_static_url+'app/logout.png'" mode="scaleToFill" class="dis-block"></image>
					<view class="tc cr-base margin-top-lg">{{$t('user.user.2k0227')}}</view>
				</view>
            </view>
			
        </view>
        <view v-else>
            <!-- 提示信息 -->
            <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
        </view>
		
		<component-footer :prop-status="2"></component-footer>
    </view>
</template>
<script>
    const app = getApp();
    import componentNoData from "@/components/no-data/no-data";
	import componentFooter from "@/pages/fcc/scorestore/public/footer";
	var scorestore_static_url = app.globalData.get_static_url('scorestore', true);
    export default {
        data() {
            return {
				scorestore_static_url: scorestore_static_url,
                data_bottom_line_status: false,
                data_list_loding_status: 1,
                data_list_loding_msg: '',
                data_base: null,
                user_score: null,
                nav_list: [],
                submit_disabled_status: false,
				gonggao:'',
				zichan_top_box:''
            };
        },

        components: {
            componentNoData,
			componentFooter
        },
        props: {},

        onLoad(params) {},

        onShow() {
			app.globalData.page_event_onshow_handle();
            this.init();

            // 分享菜单处理
            app.globalData.page_share_handle();
        },

        // 下拉刷新
        onPullDownRefresh() {
            this.get_data();
        },

        methods: {
            init(e) {
                var user = app.globalData.get_user_info(this, "init");
                if (user != false) {
                    this.get_data();
                }
            },

            // 获取数据
            get_data() {
                uni.request({
                    url: app.globalData.get_request_url("index", "user", "scorestore"),
                    method: 'POST',
                    data: {},
                    dataType: 'json',
                    success: res => {console.log(res);
                        uni.stopPullDownRefresh();
                        if (res.data.code == 0) {
                            var data = res.data.data;
							// 公告
							var gonggao = ((data.base.user_center_notice_str || null) != null) ? data.base.user_center_notice_str : '';
                            this.setData({
                                data_base: data.base || null,
								gonggao:gonggao,
                                user_score: data.user_score || null,
                                nav_list: data.nav_list || [],
                                data_list_loding_msg: '',
                                data_list_loding_status: 0,
                                data_bottom_line_status: false
                            });
							uni.setStorageSync('user_integral_base_set', data.base);
                        } else {
                            this.setData({
                                data_bottom_line_status: false,
                                data_list_loding_status: 2,
                                data_list_loding_msg: res.data.msg
                            });
                            if (app.globalData.is_login_check(res.data, this, 'get_data')) {
                                app.globalData.showToast(res.data.msg);
                            }
                        }
                    },
                    fail: () => {
                        uni.stopPullDownRefresh();
                        this.setData({
                            data_bottom_line_status: false,
                            data_list_loding_status: 2,
                            data_list_loding_msg: this.$t('common.internet_error_tips')
                        });
                        app.globalData.showToast(this.$t('common.internet_error_tips'));
                    }
                });
            },
			
			// 清除缓存
			remove_user_cache_event(e) {
			    // 调用公共方法处理
			    app.globalData.remove_user_cache_event();
			    
			    // 回到积分商城首页
				app.globalData.url_open('/pages/fcc/scorestore/index/index');
			}
        }
    };
</script>
<style>
    @import './user-integral-index.css';
</style>